package com.ruoyi.project.platform.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.platform.domain.RRunningExchange;
import com.ruoyi.project.platform.service.IRRunningExchangeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 运行机器人币对Controller
 * 
 * @author ruoyi
 * @date 2020-07-30
 */
@RestController
@RequestMapping("/platform/exchange")
public class RRunningExchangeController extends BaseController
{
    @Autowired
    private IRRunningExchangeService rRunningExchangeService;

    /**
     * 查询运行机器人币对列表
     */
    @PreAuthorize("@ss.hasPermi('platform:exchange:list')")
    @GetMapping("/list")
    public TableDataInfo list(RRunningExchange rRunningExchange)
    {
        startPage();
        List<RRunningExchange> list = rRunningExchangeService.selectRRunningExchangeList(rRunningExchange);
        return getDataTable(list);
    }

    /**
     * 导出运行机器人币对列表
     */
    @PreAuthorize("@ss.hasPermi('platform:exchange:export')")
    @Log(title = "运行机器人币对", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RRunningExchange rRunningExchange)
    {
        List<RRunningExchange> list = rRunningExchangeService.selectRRunningExchangeList(rRunningExchange);
        ExcelUtil<RRunningExchange> util = new ExcelUtil<RRunningExchange>(RRunningExchange.class);
        return util.exportExcel(list, "exchange");
    }

    /**
     * 获取运行机器人币对详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:exchange:query')")
    @GetMapping(value = "/{runningId}")
    public AjaxResult getInfo(@PathVariable("runningId") Long runningId)
    {
        return AjaxResult.success(rRunningExchangeService.selectRRunningExchangeById(runningId));
    }

    /**
     * 新增运行机器人币对
     */
    @PreAuthorize("@ss.hasPermi('platform:exchange:add')")
    @Log(title = "运行机器人币对", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RRunningExchange rRunningExchange)
    {
        return toAjax(rRunningExchangeService.insertRRunningExchange(rRunningExchange));
    }

    /**
     * 修改运行机器人币对
     */
    @PreAuthorize("@ss.hasPermi('platform:exchange:edit')")
    @Log(title = "运行机器人币对", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RRunningExchange rRunningExchange)
    {
        return toAjax(rRunningExchangeService.updateRRunningExchange(rRunningExchange));
    }

    /**
     * 删除运行机器人币对
     */
    @PreAuthorize("@ss.hasPermi('platform:exchange:remove')")
    @Log(title = "运行机器人币对", businessType = BusinessType.DELETE)
	@DeleteMapping("/{runningIds}")
    public AjaxResult remove(@PathVariable Long[] runningIds)
    {
        return toAjax(rRunningExchangeService.deleteRRunningExchangeByIds(runningIds));
    }
}
